package de.projectgoodmorning.util;

import java.io.UnsupportedEncodingException;


public class ByteConverter {

	public static final String UTF_8_ENCODING = "UTF-8";
	public static final String ASCII_ENCODING = "ASCII";
	
	public static byte[] fromString( String s ) {
		try {
			return s.getBytes( ASCII_ENCODING );
		} catch( UnsupportedEncodingException e ) {
			e.printStackTrace();
			return null;
		}
	}
	
	public static String fromByteToString( byte[] bytes, int length ) {
		try {
			String s = new String( bytes, ASCII_ENCODING );
			return s.substring( 0, length );
		} catch( UnsupportedEncodingException e ) {
			e.printStackTrace();
			return null;
		}
	}
}